package com.ruoyi.web.controller.basedata;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.basedata.domain.BillSettlement;
import com.ruoyi.basedata.service.IBillSettlementService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 费用结算Controller
 * 
 * @author gdqt
 * @date 2025-04-23
 */
@RestController
@RequestMapping("/basedata/settlement")
public class BillSettlementController extends BaseController
{
    @Autowired
    private IBillSettlementService billSettlementService;

    /**
     * 查询费用结算列表
     */
    @PreAuthorize("@ss.hasPermi('basedata:settlement:list')")
    @GetMapping("/list")
    public TableDataInfo list(BillSettlement billSettlement)
    {
        startPage();
        List<BillSettlement> list = billSettlementService.selectBillSettlementList(billSettlement);
        return getDataTable(list);
    }

    /**
     * 导出费用结算列表
     */
    @PreAuthorize("@ss.hasPermi('basedata:settlement:export')")
    @Log(title = "费用结算", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BillSettlement billSettlement)
    {
        List<BillSettlement> list = billSettlementService.selectBillSettlementList(billSettlement);
        ExcelUtil<BillSettlement> util = new ExcelUtil<BillSettlement>(BillSettlement.class);
        util.exportExcel(response, list, "费用结算数据");
    }

    /**
     * 获取费用结算详细信息
     */
    @PreAuthorize("@ss.hasPermi('basedata:settlement:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(billSettlementService.selectBillSettlementById(id));
    }

    /**
     * 新增费用结算
     */
    @PreAuthorize("@ss.hasPermi('basedata:settlement:add')")
    @Log(title = "费用结算", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BillSettlement billSettlement)
    {
        return toAjax(billSettlementService.insertBillSettlement(billSettlement));
    }

    /**
     * 修改费用结算
     */
    @PreAuthorize("@ss.hasPermi('basedata:settlement:edit')")
    @Log(title = "费用结算", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BillSettlement billSettlement)
    {
        return toAjax(billSettlementService.updateBillSettlement(billSettlement));
    }

    /**
     * 删除费用结算
     */
    @PreAuthorize("@ss.hasPermi('basedata:settlement:remove')")
    @Log(title = "费用结算", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(billSettlementService.deleteBillSettlementByIds(ids));
    }
}
